package cn.lili.modules.goods.entity.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 商品编辑DTO
 *
 * @author pikachu
 * @since 2020-02-24 19:27:20
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ProxyGoodsOperationDTO implements Serializable {


    private static final long serialVersionUID = -4008991091843977249L;

    @ApiModelProperty(hidden = true)
    private String goodsId;

    @ApiModelProperty(value = "商品价格", required = true)
    @NotNull(message = "商品价格不能为空")
    @Min(value = 0, message = "商品价格不能为负数")
    @Max(value = 99999999, message = "商品价格不能超过99999999")
    private Double price;

    @ApiModelProperty(value = "店铺分类id", required = true)
    @Size(max = 200, message = "选择了太多店铺分类")
    private String storeCategoryPath;


    @ApiModelProperty(value = "商品名称", required = true)
    @NotEmpty(message = "商品名称不能为空")
    @Length(max = 50, message = "商品名称不能超过50个字符")
    private String goodsName;

    @ApiModelProperty(value = "详情")
    private String intro;

    @ApiModelProperty(value = "商品移动端详情")
    private String mobileIntro;

    @ApiModelProperty(value = "是否立即发布")
    private Boolean release;

    @ApiModelProperty(value = "是否是推荐商品")
    private Boolean recommend;

    @ApiModelProperty(value = "是否立即上架", required = true)
    private Boolean readyForSale = false;

    @ApiModelProperty(value = "商品图片")
    private List<String> goodsGalleryList;

    @ApiModelProperty(value = "运费模板id,不需要运费模板时值是0", required = true)
    @NotNull(message = "运费模板不能为空，没有运费模板时，传值0")
    @Min(value = 0, message = "运费模板值不正确")
    private String templateId;

    @ApiModelProperty(value = "sku列表")
    private List<Map<String, Object>> skuList;

    @ApiModelProperty(value = "卖点")
    private String sellingPoint;


    @ApiModelProperty(value = "商品描述")
    private String info;


    /**
     * 商品视频
     */
    @ApiModelProperty(value = "商品视频")
    private String goodsVideo;

    /**
     * 是否是绿色商品
     */
    @ApiModelProperty(value = "是否是绿色商品")
    private Boolean isGreenGoods = false;

    @ApiModelProperty(value = "是否公益商品")
    private Boolean isCommonwealGoods = false;

    @ApiModelProperty(value = "是否会员商品")
    private Boolean isVipGoods = false;

    @ApiModelProperty(value = "默认商品的绿色积分")
    private BigDecimal defaultSkuGreenScore;

    @ApiModelProperty(value = "是否绿色积分卷抵扣")
    private Boolean isGreenSecurities;

    @ApiModelProperty(value = "规格参数")
    private String specParameter;

    @ApiModelProperty(value = "是否演唱会门票")
    private Boolean isTicket;

    @ApiModelProperty(value = "是否套餐商品")
    private Boolean isMeal;

    @ApiModelProperty(value = "是否是分销商品")
    private Boolean isDistributionGoods;
    public String getGoodsName() {
        //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤，影响很大。
        // 业务中，全局代码中只有商品名称不能拥有英文逗号，是由于商品名称存在一个数据库联合查询，结果要根据逗号分组
        return goodsName.replace(",", "");
    }

}
